<template>
  <div id="app">
      <el-container>
        <el-header>       
          <span style="float:left" v-if="sesUser!=null">
            {{sesUser.uname}},欢迎你!
              <el-button @click="logout" type="danger">注销</el-button>
            </span>
          Element UI </el-header>
        <el-container>
          <el-aside width="200px">
              <el-menu
                 router
                default-active="2"
                class="el-menu-vertical-demo" 
                background-color="#545c64"
                text-color="#fff"
                active-text-color="#ffd04b">

                  <el-menu-item 
                   v-for="route in $router.options.routes"
                   :key="route.path"
                    :index="route.path">
                      <i class="el-icon-menu"></i>
                      <span slot="title">{{route.title}}</span>
                    </el-menu-item>


              </el-menu> 

          </el-aside>
          <el-main><router-view></router-view></el-main>
        </el-container>
         <el-footer>
           <a target="_blank" href="https://element.eleme.io/">Element UI</a>
         </el-footer>
      </el-container>
  </div>
</template>

<script>
export default {
  name: 'App',
  computed:{
    sesUser(){      
     return this.$store.getters.getSesUser; 
    }
  },
  methods:{
    logout(){
      this.$axios.get("login/logout").then(resp=>{
       this.$store.dispatch("change","login");
       this.$store.dispatch("logout");
       });
    }
  },
  mounted(){
    //console.log(this.$router);
  }
}
</script>

<style>
.el-header, .el-footer {
    background-color: #B3C0D1;
    color: white;
    text-align: center;
    line-height: 60px;
  }
  
  .el-aside {
    background-color: #D3DCE6;
    color: #333; 
    line-height: 30px;
    min-height: 520px;
  }
  
  .el-main {
    background-color: #E9EEF3;
    color: #333; 
    line-height: 30px;
  }

  .el-menu{
    min-height: 520px;
  }
</style>
